package com.model.defaults.actionbar;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionBarItem;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.UserContextName;


public class ModelDefaultActionbarItemsUser {

    public static void createActionBarItemsUserList ( Session session,
                                                      Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("UserAdd");
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERSLIST);
        pojo = new ActionBarItem();
        pojo.setName("AddUser");
        pojo.setCaption("Add user");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }



    public static void createActionBarItemsUserInfo ( Session session,
                                                      Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;

        KeyValue actionScriptParam = new KeyValue("p3", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("UserUpdate?{p3}");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERINFO);
        pojo = new ActionBarItem();
        pojo.setName("EditDescription");
        pojo.setCaption("Edit user attributes");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);
    }



    public static void createActionBarItemsUserAdd ( Session session,
                                                     Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERADD);

        KeyValue actionScriptParam = new KeyValue("form", "?");
        session.save(actionScriptParam);

        ActionScript actionScript = new ActionScript();
        actionScript.setActionScriptType("javascript");
        actionScript.setActionScriptText("javascript:document.{form}.submit();");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("saveUser");
        pojo.setCaption("Save new user");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

        actionScriptParam = new KeyValue("p3", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("UserResetPassword?{p3}");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("resetPassword");
        pojo.setCaption("ResetPassword");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);
    }



    public static void createActionBarItemsUserUpdate ( Session session,
                                                        Map <String, UserContextName> userContexts ) {

        UserContextName contextName_1 = null;
        ActionBarItem pojo = null;
        ActionScript actionScript = null;
        KeyValue actionScriptParam = null;
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERUPDATE);

        actionScriptParam = new KeyValue("form", "?");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptType("javascript");
        actionScript.setActionScriptText("javascript:document.{form}.submit();");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("saveProject");
        pojo.setCaption("Save user");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

        actionScriptParam = new KeyValue("p3", "?");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("UserResetPassword?{p3}");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        pojo = new ActionBarItem();
        pojo.setName("resetPassword");
        pojo.setCaption("ResetPassword");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }
}
